package com.talkweb.securitycamera.utils.eventlib.pool;


import com.talkweb.securitycamera.utils.eventlib.communicationevent.IEventReset;

/**
 * @version 1.0.1
 * @description: IEvent对象池（线程安全）
 * @program: Gallery
 * @Author xiaozhijun
 * @Date 2020/12/22 17:20
 */
public class AsynEventPools<T extends IEventReset> extends EventPools<T> {

    private final Object mLock = new Object();

    public AsynEventPools(int maxPoolSize) {
        super(maxPoolSize);
    }

    @Override
    public T acquire() {
        //通过synchronized实现同步
        synchronized (mLock) {
            return super.acquire();
        }
    }

    @Override
    public boolean release(T element) {
        synchronized (mLock) {
            return super.release(element);
        }
    }
}
